﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:Microsoft.Samples"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    mc:Ignorable="d">

    <Style
        TargetType="local:Webcam">
        <Setter
            Property="Template">
            <Setter.Value>
                <ControlTemplate
                    TargetType="local:Webcam">
                    <Grid
                        d:DesignWidth="249"
                        d:DesignHeight="159">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup
                                x:Name="CommonStates">
                                <VisualState
                                    x:Name="NotRecording">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetProperty="(UIElement.Visibility)"
                                            Storyboard.TargetName="_recordingFrame">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetProperty="(UIElement.Visibility)"
                                            Storyboard.TargetName="_cameraOff">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetProperty="(UIElement.Visibility)"
                                            Storyboard.TargetName="_cameraOn">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState
                                    x:Name="Recording">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetProperty="(UIElement.Visibility)"
                                            Storyboard.TargetName="_cameraOn">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetProperty="(UIElement.Visibility)"
                                            Storyboard.TargetName="_recordingFrame">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetProperty="(UIElement.Visibility)"
                                            Storyboard.TargetName="_cameraOff">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup
                                x:Name="DevicesStates">
                                <VisualState
                                    x:Name="OneDevice">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetProperty="(UIElement.Visibility)"
                                            Storyboard.TargetName="_devices">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState
                                    x:Name="MultipleDevices">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetProperty="(UIElement.Visibility)"
                                            Storyboard.TargetName="_devices">
                                            <DiscreteObjectKeyFrame
                                                KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Rectangle
                            x:Name="_targetRectangle"
                            Fill="White" />

                        <Grid
                            x:Name="_recordingFrame"
                            Margin="8">
                            <Rectangle
                                Stroke="Red"
                                StrokeThickness="2" />
                            <StackPanel
                                Margin="4,1,0,0"
                                Orientation="Horizontal"
                                VerticalAlignment="Top"
                                HorizontalAlignment="Left">
                                <Ellipse
                                    StrokeThickness="2"
                                    VerticalAlignment="Center"
                                    Fill="Red"
                                    Width="8"
                                    Height="8"
                                    Margin="0,0,2,0" />
                                <TextBlock
                                    TextWrapping="Wrap"
                                    Text="Rec"
                                    d:LayoutOverrides="Height"
                                    Foreground="Red"
                                    VerticalAlignment="Center" />
                            </StackPanel>
                        </Grid>

                        <StackPanel
                            Margin="0"
                            Orientation="Horizontal"
                            VerticalAlignment="Bottom"
                            HorizontalAlignment="Center">
                            <Button
                                x:Name="_cameraOn"
                                Margin="0">
                                <Ellipse
                                    Height="15"
                                    Stroke="Red"
                                    Width="15"
                                    Margin="2" />
                            </Button>
                            <Button
                                x:Name="_cameraOff"
                                Margin="0">
                                <Rectangle
                                    Fill="#FFF4F4F5"
                                    Height="15"
                                    Stroke="Black"
                                    Width="15"
                                    Margin="2" />
                            </Button>
                        </StackPanel>
                        <ComboBox
                            x:Name="_devices"
                            Margin="0"
                            VerticalAlignment="Top"
                            HorizontalAlignment="Center"
                            MinWidth="150" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>
